//
//  ViewController.m
//  JSMBing
//
//  Created by 刘茂峰 on 15/12/7.
//  Copyright © 2015年 cn.sijian. All rights reserved.
//

#import "ViewController.h"
#import "JSMBing.h"
@interface ViewController ()<JSMBingDataSource>
@property (nonatomic,weak) JSMBing *bing;
@property (nonatomic,strong) NSMutableArray *arrM;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    JSMBing *bing=[[JSMBing alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];

    bing.dataSource=self;
    bing.center=self.view.center;
    [self.view addSubview: bing];
    self.bing=bing;
}
- (IBAction)cleanclick:(id)sender {
    self.arrM =[NSMutableArray array];
    [self.bing reloadData];
}
- (IBAction)click:(id)sender {
    [self.arrM addObject:@(arc4random_uniform(100))];
    [self.bing reloadData];
}
//-(UIColor *)JSMBingColor:(JSMBing *)bing andIndex:(NSInteger)index
//{
//    return index%2==0? [UIColor redColor]:[UIColor blueColor];
//}
-(NSArray *)JSMBingData:(JSMBing *)bing
{
    return self.arrM;
}
-(NSMutableArray *)arrM
{
    if (_arrM==nil) {
        _arrM=[NSMutableArray array];
    }
    return _arrM;
}


@end
